/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package exatrez.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author fikri
 */
@Entity
@Table(name = "vessel")
@NamedQueries({
    @NamedQuery(name = "Vessel.findAll", query = "SELECT v FROM Vessel v")})
public class Vessel implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "vessel_id")
    private Integer vesselId;
    @Column(name = "vessel_name")
    private String vesselName;
    @Column(name = "vessel_abbr")
    private String vesselAbbr;
    @Column(name = "active")
    private Character active;

    
    /* For Ship Visit*/
    @Column(name = "imo")
    private String imo;
    
     @Column(name = "gross")
    private String gross;
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "superintendence_id")
    private User superintendence;
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "crew_id")
    private User crewExe;
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "proc_id")
    private User procExe;
    
    @OneToMany (mappedBy = "vessel" , fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List<Gallery> galleryList;
    
    @Embedded
    private InfoAudit infoAudit;

    public Vessel() {
    }

    public Vessel(Integer vesselId) {
        this.vesselId = vesselId;
    }   

    public Integer getVesselId() {
        return vesselId;
    }

    public void setVesselId(Integer vesselId) {
        this.vesselId = vesselId;
    }

    public String getVesselName() {
        return vesselName;
    }

    public void setVesselName(String vesselName) {
        this.vesselName = vesselName;
    }

    public Character getActive() {
        return active;
    }

    public void setActive(Character active) {
        this.active = active;
    }

    public InfoAudit getInfoAudit() {
        return infoAudit;
    }

    public void setInfoAudit(InfoAudit infoAudit) {
        this.infoAudit = infoAudit;
    }    

    public User getSuperintendence() {
        return superintendence;
    }

    public void setSuperintendence(User superintendence) {
        this.superintendence = superintendence;
    }

    public List<Gallery> getGalleryList() {
        return galleryList;
    }

    public void setGalleryList(List<Gallery> galleryList) {
        this.galleryList = galleryList;
    }

    public String getVesselAbbr() {
        return vesselAbbr;
    }

    public void setVesselAbbr(String vesselAbbr) {
        this.vesselAbbr = vesselAbbr;
    }   

    public String getImo() {
        return imo;
    }

    public void setImo(String imo) {
        this.imo = imo;
    }

    public String getGross() {
        return gross;
    }

    public void setGross(String gross) {
        this.gross = gross;
    }

    public User getCrewExe() {
        return crewExe;
    }

    public void setCrewExe(User crewExe) {
        this.crewExe = crewExe;
    }

    public User getProcExe() {
        return procExe;
    }

    public void setProcExe(User procExe) {
        this.procExe = procExe;
    }
    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (vesselId != null ? vesselId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Vessel)) {
            return false;
        }
        Vessel other = (Vessel) object;
        if ((this.vesselId == null && other.vesselId != null) || (this.vesselId != null && !this.vesselId.equals(other.vesselId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "exatrez.model.Vessel[ vesselId=" + vesselId + " ]";
    }
    
}
